﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Terra.Core.Common.Enums.Identity;
using Terra.Core.Common.Models.Pagination;
using Terra.Data.Entities.Identity;
using Terra.Data.Models.Identity;

namespace Terra.Service.Identity.Interfaces
{
    /// <summary>
    /// 用户服务接口
    /// </summary>
    public interface IUserService
    {
        /// <summary>
        /// 获取用户
        /// </summary>
        /// <param name="id">用户ID</param>
        /// <returns>用户实体</returns>
        Task<User> GetUserAsync(Guid id);

        /// <summary>
        /// 分页查询用户
        /// </summary>
        /// <param name="query">查询条件</param>
        /// <returns>分页结果</returns>
        Task<PagedList<UserItemDto>> GetPagedUsersAsync(UserQueryDto query);

        /// <summary>
        /// 获取用户详情
        /// </summary>
        /// <param name="id">用户ID</param>
        /// <returns>用户详情</returns>
        Task<UserDetailDto> GetUserDetailAsync(Guid id);

        /// <summary>
        /// 创建用户
        /// </summary>
        /// <param name="dto">创建参数</param>
        /// <returns>创建的用户ID</returns>
        Task<Guid> CreateUserAsync(UserCreateDto dto);

        /// <summary>
        /// 更新用户
        /// </summary>
        /// <param name="dto">更新参数</param>
        /// <returns>更新结果</returns>
        Task<bool> UpdateUserAsync(UserUpdateDto dto);

        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="id">用户ID</param>
        /// <returns>删除结果</returns>
        Task<bool> DeleteUserAsync(Guid id);

        /// <summary>
        /// 批量删除用户
        /// </summary>
        /// <param name="ids">用户ID列表</param>
        /// <returns>删除数量</returns>
        Task<int> BatchDeleteUsersAsync(List<Guid> ids);

        /// <summary>
        /// 更改密码
        /// </summary>
        /// <param name="dto">更改密码参数</param>
        /// <returns>更改结果</returns>
        Task<bool> ChangePasswordAsync(ChangePasswordDto dto);

        /// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="dto">重置密码参数</param>
        /// <returns>重置结果</returns>
        Task<bool> ResetPasswordAsync(ResetPasswordDto dto);

        /// <summary>
        /// 更新用户状态
        /// </summary>
        /// <param name="dto">状态更新参数</param>
        /// <returns>更新结果</returns>
        Task<bool> UpdateUserStatusAsync(UserStatusUpdateDto dto);

        /// <summary>
        /// 为用户分配角色
        /// </summary>
        /// <param name="dto">角色分配参数</param>
        /// <returns>操作结果</returns>
        Task<bool> AssignRolesToUserAsync(UserRoleAssignDto dto);

        /// <summary>
        /// 检查用户名是否存在
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="excludeUserId">排除的用户ID</param>
        /// <returns>是否存在</returns>
        Task<bool> IsUserNameExistsAsync(string userName, Guid? excludeUserId = null);

        /// <summary>
        /// 检查邮箱是否存在
        /// </summary>
        /// <param name="email">邮箱</param>
        /// <param name="excludeUserId">排除的用户ID</param>
        /// <returns>是否存在</returns>
        Task<bool> IsEmailExistsAsync(string email, Guid? excludeUserId = null);

        /// <summary>
        /// 检查手机号是否存在
        /// </summary>
        /// <param name="phoneNumber">手机号</param>
        /// <param name="excludeUserId">排除的用户ID</param>
        /// <returns>是否存在</returns>
        Task<bool> IsPhoneNumberExistsAsync(string phoneNumber, Guid? excludeUserId = null);
    }
}
